<?php
/**
 * Created by PhpStorm.
 * User: Qch
 * Date: 2016/9/8
 * Time: 16:36
 */

namespace J\Storage;

/**
 * 内存临时缓存
 */
class ArrayCache extends Cache
{
    /**
     * @var array 数据内存
     */
    protected $values = [];

    /**
     * @var bool 是否修改过
     */
    protected $modified = false;

    public function get($key, $column = null)
    {
        return array_isset($this->values, $key, $column);
    }

    public function set($pairs, $keys = null)
    {
        $this->values = array_merge($this->values, $pairs);
        $this->modified = true;
    }

    public function hasItem($key, $expire = null)
    {
        return isset($this->values, $key);
    }

    public function clear()
    {
        $this->values = [];
    }

    function itemDelete($key)
    {
        unset($this->values[$key]);
        $this->modified = true;
    }

    function isModified()
    {
        return $this->modified;
    }
}